DEV C ++ Error: expected declaration before '}' token
Posted
by
Francesca
on Stack Overflow
See other posts from Stack Overflow
or by Francesca
Published on 2011-03-12T06:11:57Z
Indexed on
2012/06/09
10:40 UTC
Read the original article
Hit count: 433
c++
What does this mean? My program goes like this: (NOTE: The line that has the error was the line coming before case 2.)
case 1:
{
cout<< "C * H * E * M * I * S * T * R * Y \n\n";
cout<< "1) What is the valence electron configuration of Selenium (Se)?\n\n";
cout<< "\na) 1s2 2s2 2p6 3s2\n\n";
cout<< "\nb) 1s2 2s2 2p2\n\n";
cout<< "\nc)4s2 4p4\n\n";
cout<< "\nd) 1s2 2s2 2p6 3s2 3p6 4s2 3d10 4p6 5s2 4d10 5p5\n\n";
cout<< "Enter your answer:\n";
cin>> answer;
if (answer == 'c')
{
cout<<"Your answer is correct. Please press the enter key to proceed to the next question.\n\n";
}
else
cout<< "The correct answer is C. Please press the enter key to proceed to the next question.\n\n";
getch ();
}
getch ();
cout<< "2) Which element yields the biggest atomic radius?\n\n";
cout<< "\na) Ca\n\n";
cout<< "\nb) Xe\n\n";
cout<< "\nc) B\n\n";
cout<< "\nd) Cs\n\n";
cout<< "Enter your answer:\n";
cin>> answer;
if (answer == 'd')
{
cout<< "Your answer is correct. Please press the enter key to proceed to the next question.\n\n";
}
else
cout<< "The correct answer is D. Please press the enter key to proceed to the next question.\n\n";
getch ();
}
cout<< "3) Name the ionic compound K2 Cr2 O7\n\n";
cout<< "\na) potassium chloride\n\n";
cout<< "\nb) potassium carbonate\n\n";
cout<< "\nc) potassium chromite\n\n";
cout<< "\nd) potassium chromate\n\n";
cout<< "Enter your answer:\n";
cin>> answer;
if (answer == 'd')
{
cout<< "Your answer is correct. Please press the enter key to proceed to the next question.\n\n";
}
else
cout<< "The correct answer is D. Please press the enter key to proceed to the next question.\n\n";
getch ();
}
}
case 2:
{
cout<< "G * E * O * M * E * T * R * Y \n\n";
The error, as noted in the title is expected declaration before '}' token
at the line noted in my opening paragraph.
© Stack Overflow or respective owner